<template>
	<view class="Jy_group_barg_page"
		:style="tabsIndex == 0 ? 'background-color: #ff7500;' : 'background-color: #f83600;'">
		<view class="Jy_group_barg_box" :style="{'padding-top' : statusBarHeight + 'px'}">
			<view class="left-back-box" @click="getBack()">
				<u-icon name="arrow-left" color="#ffffff" size="26"></u-icon>
			</view>
			<!-- <view class="tabs_group">
				<view :class="tabsIndex == index ? 'tabs_box1' : 'tabs_box'" v-for="(item, index) in tabsList"
					:key="index" @click="getTabsChange(index)">
					<view class="tabs_text_box">
						<text>{{item.name}}</text>
					</view>
					<view class="line"
						:style="index == 0 ? 'background-color: #f83600;' : 'background-color: #ff7500;'"></view>
				</view>
			</view> -->
		</view>

		<view class="Jy_content_main_group">
			<scroll-view scroll-y="true" :style="{'height' : 'calc(100vh - ' + statusBarHeight + 'px - 80rpx);'}">
				<view class="Jy_content_main_boxs">
					<view class="active_group_bg_image" >
						<image src="https://f0.0sm.com/node0/2023/03/8640D484FB879A1A-4f7faad161479ebb.png"
							mode="widthFix"></image>
					</view>

					<!-- 拼团活动为空展示 -->
					<view class="">
						<view class="">
							<view class="">

							</view>
							<view class="">

							</view>
						</view>
					</view>

					<!-- 拼团活动头像组 / 拼团人数数量显示 -->
					<view class="active1_cy_group" >
						<view class="active1_cy_box">
							<view class="auathr_image_box">

							</view>
							<view class="number_box">
								<text>{{totalPeople}}</text>
								<text>人参与</text>
							</view>
						</view>
					</view>

				
					<view class="Jy_content_main_shop_list" v-for="(item, index) in combinationList" :key="index">
						<view class="Jy_content_main_shop_container">
							<view class="left-image-box">
								<image :src="item.image" mode="aspectFill">
								</image>
							</view>
							<view class="right_content_group">
								<view class="shop_name_box">
									<text>{{item.title}}</text>
								</view>
								<view class="shop_down-time-box">
									<view class="old_price-box">
										<text>￥{{item.otPrice}}</text>
									</view>
									
								</view>
								<view class="bar-button-group">
									<view class="news-price-box">
										<view class="new-price">
											<text class="symbal">￥</text>
											<text class="size">{{item.price}}</text>
										</view>
									</view>
									<view class="button-group">
										<view class="group-button-group">
											<view class="number-box">
												<text>{{item.people}}人团</text>
											</view>
											<view class="go-group-button">
												<text>去拼团</text>
											</view>
										</view>
									</view>
								</view>
							</view>
						</view>
					</view>

					<view class="not_moore_active_box">
						<text>没有更多活动了~</text>
					</view>
				</view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// 适配头部导航高度
				statusBarHeight: getApp().globalData.statusBarHeight,
				tabsList: [{
						name: '拼团'
					},
					{
						name: '砍价'
					}
				],
				tabsIndex: 0,
				// 秒杀时间
				timeData: {},
				indicatorDots: false,
				circular: true,
				autoplay: true,
				interval: 3000,
				duration: 500,
				navH: '',
				combinationList: [],
				limit: 10,
				page: 1,
				blimit: 10,
				bpage: 1,
				loading: false,
				loadend: false,
				returnShow: true,
				loadTitle: '',
				avatarList: [],
				bannerList: [],
				totalPeople: 0,
				bargainSuccessList: [],
				bargainTotal: 0,
			};
		},
		onLoad(option) {
			this.tabsIndex = option.index;
			this.getCombination()
			this.getCombinationHeader()
		},
		methods: {

			getCombinationHeader() {
				let that = this
				this.sendRequest({
					url: "/api/front/combination/header",
					success: res => {
						this.avatarList = res.data.data.avatarList || [];
						this.bannerList = res.data.data.bannerList || [];
						this.totalPeople = res.data.data.totalPeople;
					}
				})

			},
			getCombination() {
				var that = this;
				if (that.loadend) return;
				if (that.loading) return;
				that.loadTitle = '';
				var data = {
					page: that.page,
					limit: that.limit
				};
				this.loading = true
				// 获取拼团商品
				this.sendRequest({
					url: "/api/front/combination/list",
					data: data,
					// method: 'post',
					success: res => {
						let list = res.data.data.list;
						// let combinationList = that.$util.SplitArray(list, that.combinationList);
						let loadend = list.length < that.limit;
						that.loadend = loadend;
						that.loading = false;
						that.loadTitle = loadend ? '已全部加载' : '加载更多';
						that.$set(that, 'combinationList', list);
						that.$set(that, 'page', that.page + 1);
					}
				})
			},

			// 返回上一页
			getBack() {
				uni.navigateBack();
			},
			// tabs切换
			getTabsChange(index) {
				this.tabsIndex = index;
			},
			// 秒杀倒计时变化
			onChange(e) {
				this.timeData = e
			},
			// 跳转到砍价操作页面
			getBargainPage() {
				uni.navigateTo({
					url: '/pagesH/main/customerHome/bargain/bargain'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import 'combinationDetail.scss';
</style>
